namespace Monopoly
{
    public class Board
    {
        public const int SIZE = 40;

        internal Square[] _squares = new Square[SIZE];

        public Board()
        {
            InitSquares();
        }

        public Square GoSquare
        {
            get {  return  _squares[0]; }
        }

        public Square DestinationSquare
        {
            get {return _squares[SIZE-1]; }
        }

        private void InitSquares()
        {
            for (int i = 0; i < SIZE; i++)
            {
                _squares[i] = new Square("Square_" + i, i);
            }
        }

        public Square GetSquareWithOffset(Square location, int offset)
        {
            return _squares[GetWrapARoundIndex(location, offset)];
        }

        public static int GetWrapARoundIndex(Square location, int offset)
        {
            return (location.Index + offset) % SIZE;
        }
    }
}
